// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ml
{
	public sealed partial class ModelPlotConfig
	{
		[JsonInclude]
		[JsonPropertyName("annotations_enabled")]
		public bool? AnnotationsEnabled { get; set; }

		[JsonInclude]
		[JsonPropertyName("enabled")]
		public bool? Enabled { get; set; }

		[JsonInclude]
		[JsonPropertyName("terms")]
		public Elastic.Clients.Elasticsearch.Field? Terms { get; set; }
	}

	public sealed partial class ModelPlotConfigDescriptor<TDocument> : SerializableDescriptorBase<ModelPlotConfigDescriptor<TDocument>>
	{
		internal ModelPlotConfigDescriptor(Action<ModelPlotConfigDescriptor<TDocument>> configure) => configure.Invoke(this);
		public ModelPlotConfigDescriptor() : base()
		{
		}

		private bool? AnnotationsEnabledValue { get; set; }

		private bool? EnabledValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field? TermsValue { get; set; }

		public ModelPlotConfigDescriptor<TDocument> AnnotationsEnabled(bool? annotationsEnabled = true)
		{
			AnnotationsEnabledValue = annotationsEnabled;
			return Self;
		}

		public ModelPlotConfigDescriptor<TDocument> Enabled(bool? enabled = true)
		{
			EnabledValue = enabled;
			return Self;
		}

		public ModelPlotConfigDescriptor<TDocument> Terms(Elastic.Clients.Elasticsearch.Field? terms)
		{
			TermsValue = terms;
			return Self;
		}

		public ModelPlotConfigDescriptor<TDocument> Terms<TValue>(Expression<Func<TDocument, TValue>> terms)
		{
			TermsValue = terms;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (AnnotationsEnabledValue.HasValue)
			{
				writer.WritePropertyName("annotations_enabled");
				writer.WriteBooleanValue(AnnotationsEnabledValue.Value);
			}

			if (EnabledValue.HasValue)
			{
				writer.WritePropertyName("enabled");
				writer.WriteBooleanValue(EnabledValue.Value);
			}

			if (TermsValue is not null)
			{
				writer.WritePropertyName("terms");
				JsonSerializer.Serialize(writer, TermsValue, options);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class ModelPlotConfigDescriptor : SerializableDescriptorBase<ModelPlotConfigDescriptor>
	{
		internal ModelPlotConfigDescriptor(Action<ModelPlotConfigDescriptor> configure) => configure.Invoke(this);
		public ModelPlotConfigDescriptor() : base()
		{
		}

		private bool? AnnotationsEnabledValue { get; set; }

		private bool? EnabledValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field? TermsValue { get; set; }

		public ModelPlotConfigDescriptor AnnotationsEnabled(bool? annotationsEnabled = true)
		{
			AnnotationsEnabledValue = annotationsEnabled;
			return Self;
		}

		public ModelPlotConfigDescriptor Enabled(bool? enabled = true)
		{
			EnabledValue = enabled;
			return Self;
		}

		public ModelPlotConfigDescriptor Terms(Elastic.Clients.Elasticsearch.Field? terms)
		{
			TermsValue = terms;
			return Self;
		}

		public ModelPlotConfigDescriptor Terms<TDocument, TValue>(Expression<Func<TDocument, TValue>> terms)
		{
			TermsValue = terms;
			return Self;
		}

		public ModelPlotConfigDescriptor Terms<TDocument>(Expression<Func<TDocument, object>> terms)
		{
			TermsValue = terms;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (AnnotationsEnabledValue.HasValue)
			{
				writer.WritePropertyName("annotations_enabled");
				writer.WriteBooleanValue(AnnotationsEnabledValue.Value);
			}

			if (EnabledValue.HasValue)
			{
				writer.WritePropertyName("enabled");
				writer.WriteBooleanValue(EnabledValue.Value);
			}

			if (TermsValue is not null)
			{
				writer.WritePropertyName("terms");
				JsonSerializer.Serialize(writer, TermsValue, options);
			}

			writer.WriteEndObject();
		}
	}
}